/*
 * Created by SharpDevelop.
 * User: nebulom
 * Date: 8/26/2009
 * Time: 7:53 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Miming.CashRegister.Gui
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		static MainForm instance = new MainForm();
		
		public static MainForm Instance {
			get { return instance; }
			set { instance = value; }
		}
		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			AddChild(new LoginPane());
			Text = Util.ApplicationUtility.ProductNameAndVersion;
		}
		
		public void AddChild(Control control)
		{
			panel2.Controls.Clear();
			panel2.Controls.Add(control);
		}
		
		public DialogResult AddDialog(Form form)
		{
			form.StartPosition = FormStartPosition.CenterParent;
			form.FormBorderStyle = FormBorderStyle.FixedDialog;
			form.KeyPreview = true;
			form.MinimizeBox = form.MaximizeBox = form.ShowInTaskbar = false;
			form.KeyDown += delegate(object sender, KeyEventArgs e) { 
				if (e.KeyCode == Keys.Escape) {
					form.Close();
				}
			};
			return form.ShowDialog(this);
		}
	}
}
